﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.Business.Prices {
    internal class SummaryPriceModifiers {

        #region Fields

        private double price;
        private double priceWithoutRabat;

        #endregion

        #region Methods

        internal void Set(double initialPrice, DateTime priceForDay, ApartmentPriceModifier[] apartmentPriceModifier) {
            double modValue = 0;
            double modPercent = 0;
            double newInitialPrice = 0;

            foreach (ApartmentPriceModifier modifier in apartmentPriceModifier) {
                modPercent += modifier.GetPercentModification(priceForDay);
                modValue += modifier.GetValueModification(priceForDay);
                newInitialPrice = modifier.GetNewValue(priceForDay);
                if (newInitialPrice > 0)
                    initialPrice = newInitialPrice;
            }
            this.priceWithoutRabat = initialPrice + modValue;
            this.price = this.priceWithoutRabat + this.priceWithoutRabat * modPercent / 100;

        }

        internal double GetPrice() {
            return this.price;
        }

        internal double GetPriceWithoutRabat() {
            return this.priceWithoutRabat;
        }

        #endregion

    }
}
